Skip to content

Conversation

Dakkaron
Copy link

@Dakkaron Dakkaron commented Dec 30, 2020

I created a little Python script (I know, this is a Haskell project, but I am really no good with Haskell) that allows users to use Amazon Polly as a TTS engine.

Since Amazon Polly uses an XML format for their TTS engine (you can upload plain text as well, but the XML can be used to add tons of nice effects to the voice) I split the voice generation file from the game YAML. I don't like mixing markup languages because the escape sequences can become quite convoluted.

It requires boko3 to be installed (pip3 install boko3)

This is related to issue #248.

As a demo, see the input and output files in the attached polly.zip.
polly.zip

@KOTRET
Copy link

KOTRET commented Jan 1, 2021

great idea, although the speech synth is not that good related to the german language :D
Guess this is something for the wiki.

@Dakkaron
Copy link
Author

Dakkaron commented Jan 1, 2021

It's not as good as the neural voices they have for english, but it's much better than the one integrated in tttool.

@PetrVys
Copy link

PetrVys commented Oct 10, 2025

This is a great idea - I made something similar for elevenlabs. The quality is quite stunning. Name the below espeak.py, use pyinstaller to turn it into .exe and replace the bundled espeak.exe to use. You select the voice/user via language id in the yaml file (e.g. language: JBFqnCBsd6RMkjVDRZzb)

from elevenlabs.client import ElevenLabs
import os
import sys
import wave

elevenlabs = ElevenLabs(
    api_key="sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
)

audio = elevenlabs.text_to_speech.convert(
    text=sys.argv[7],
    voice_id=sys.argv[2],
    model_id="eleven_v3",
#    model_id="eleven_multilingual_v2",
    output_format="pcm_16000",
)

# Collect all chunks into memory
pcm_data = b"".join(chunk for chunk in audio)

# Write directly to WAV file
with wave.open(sys.argv[4], "wb") as wav_file:
    wav_file.setnchannels(1)            # Mono
    wav_file.setsampwidth(2)            # 16-bit PCM
    wav_file.setframerate(16000)        # Sample rate
    wav_file.writeframes(pcm_data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants